<?php
    //1.引入文件，连接数据库
    require('common/conn.php');
    if(isset($_POST['submit'])){
        //2.获取所需参数
        $username = $_POST['username'];
        $content = $_POST['content'];
        $inputtime = time();

        //3.准备sql语句
        $sql = "insert into leaveword (username, content, inputtime) 
          values ('{$username}','{$content}','{$inputtime}')";

        //4.执行sql语句
        $result = mysqli_query($link,$sql);

        //5.判断执行结果
        if($result === false){
            exit('添加失败');
        }

    }

?>

<!DOCTYPE html>
<html>
<head>
    <title>Roem Blog</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/index.css" rel="stylesheet">
    <style>
        .board-wrapper {
            background: white;
            padding: 40px 20px;
        }
        
        .board-wrapper h3 {
            text-align: center;
        }
        .username {
            width: 300px;
            height: 35px;
        }
        .contact-content {
            width: 600px;
            height: 300px;
        }

        .contact-btn {
            width: 200px;
            height: 50px;
            margin-left: 60px;
            background: rgba(0, 0, 0, 0.6);
            border: 1px solid black;
            border-radius: 8px;
            color: white;
        }

    </style>

</head>

<body>

<!-- header -->
<div class="main-header">
    <div id="blogTitle">
        <h2>Roem的博客</h2>
        <h5>Love Coding, Enjoy Life !</h5>
    </div>
    <div class="nav row">
        <div class="col-md-6 col-md-offset-3">
            <div class="row">
                <div class="col-md-4"><a class="animation" href="index.php">文章 Articles</a></div>
                <div class="col-md-4"><a class="animation" href="contact.php">留言 Contact</a></div>
                <div class="col-md-4"><a class="animation" href="about.html">简介 About</a></div>
            </div>
        </div>
    </div>
</div>

<!-- main -->
<div class="content-warp" id="barba-wrapper" aria-live="polite">

    <!-- left -->
    <div class="container barba-container" style="visibility: visible;">
        <div class="row">

            <!--start main content aera-->
            <div class="col-md-9  main-content">
                <div class="board-wrapper">
                    <h3>谢谢您的留言</h3><br/><br/>

                    <form action=" " method="post">
                        用户名：<input type="text" name="username" class="username" /><br/><br/>
                        留&nbsp;&nbsp;&nbsp;言：<textarea name="content" class="contact-content"></textarea><br/><br/>
                        <input type="submit" name="submit" value="马上留言" class="contact-btn">
                    </form>
                </div>
            </div>

            <!-- right -->
            <?php require_once "right.php"; ?>
        </div>
    </div>
</div>


<!-- footer -->
<div class="main-footer">
    <div class="container">
        <div class="logo">
            Roem BLOG
        </div>
        <p>&nbsp;</p>
    </div>

    <h5 class="copyright text-center">
        © 2017 &nbsp;|&nbsp; &copy; Roem
        <a href="admin/login.php" class="no-barba no-barba-prefetch">后台管理</a>
    </h5>
</div>
</body>

</html>